<?php

/**
 * Trip form.
 *
 * @package    maximous
 * @subpackage form
 * @author     Mina.Gerges.Wadea
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class TripForm extends BaseTripForm
{

    public function configure()
    {
        $_i18n = $this->getOption('i18n');
        $this->setWidget('description', new sfWidgetFormTextarea());
        $this->setValidator('description', new sfValidatorString(array('max_length' => 300)));
        $this->setValidator('seats_number', new sfValidatorInteger(array('min' => 5)));

        $this->useFields(array('title', 'description', 'contact_information', 'seats_number', 'trip_date', 'statues'));
        $this->configureLoginUserRoleOnChangeStatusAndNeedCheck();
        $this->addFormatter('CustomFormatter');
    }

    public function doSave($con = null)
    {
        $maxUser = $this->getOption('maxUser');
        $this->getObject()->setUserId($maxUser->getUserDataByIndex('id'));
        parent::doSave($con);
    }

}
